<?php

declare (strict_types=1);
namespace App\Model;

use App\Traits\ModelLabelTrait;
use Hyperf\Database\Model\SoftDeletes;
use Hyperf\DbConnection\Model\Model;
/**
 * @property int $id 
 * @property int $material_id 
 * @property int $material_assign_id 
 * @property int $flow_type 
 * @property int $from_admin_id 
 * @property int $from_data_id 
 * @property int $from_data_type 
 * @property int $to_data_id 
 * @property int $to_data_type 
 * @property int $status 
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property string $deleted_at 
 */
class MaterialFlow extends Model
{
    use SoftDeletes,ModelLabelTrait;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'material_flow';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'material_id',
        'assign_parent_id',
        'material_assign_id',
        'flow_type',
        'from_admin_id',
        'from_data_id',
        'from_data_type',
        'to_data_id',
        'to_data_type',
        'status'
    ];

    protected $appends=[
        'status_label'
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int', 'material_id' => 'integer', 'material_assign_id' => 'integer', 'flow_type' => 'integer', 'from_admin_id' => 'integer', 'from_data_id' => 'integer', 'from_data_type' => 'integer', 'to_data_id' => 'integer', 'to_data_type' => 'integer', 'status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    const FROM_DATA_TYPE_ZERO = 0;
    const FROM_DATA_TYPE_ONE = 1;
    const FROM_DATA_TYPE_TWO = 2;
    const FROM_DATA_TYPE_THREE = 3;

    const FROM_DATA_TYPE_LABELS=[
        self::FROM_DATA_TYPE_ZERO => '文明办',
        self::FROM_DATA_TYPE_ONE => '区县',
        self::FROM_DATA_TYPE_TWO => '街道',
        self::FROM_DATA_TYPE_THREE => '社区'
    ];

    const TO_DATA_TYPE_ZERO = 0;
    const TO_DATA_TYPE_ONE = 1;
    const TO_DATA_TYPE_TWO = 2;
    const TO_DATA_TYPE_THREE = 3;

    const TO_DATA_TYPE_LABELS=[
        self::TO_DATA_TYPE_ZERO => '文明办',
        self::TO_DATA_TYPE_ONE => '区县',
        self::TO_DATA_TYPE_TWO => '街道',
        self::TO_DATA_TYPE_THREE => '社区'
    ];

    const FLOW_TYPE_ONE = 1;
    const FLOW_TYPE_TWO = 2;

    const FLOW_TYPE_LABELS=[
        self::FLOW_TYPE_ONE => '审核',
        self::FLOW_TYPE_TWO => '评分'
    ];

    const STATUS_DEFAULT = 0;
    const STATUS_VERIFYSUCCESS = 10;
    const STATUS_VERIFYFAIl = -10;
    const STATUS_WAITSCORE = 50;
    const STATUS_SCORE = 60;

    const STATUS_LABELS=[
        self::STATUS_DEFAULT => '待审核',
        self::STATUS_VERIFYSUCCESS => '审核通过',
        self::STATUS_VERIFYFAIl => '已打回',
        self::STATUS_WAITSCORE => '待打分',
        self::STATUS_SCORE => '已完成'
    ];

    public function getStatusLabelAttribute(){
        return self::getLabel('status',$this->status);
    }

}